#ifndef CALCULATOR_H
#define CALCULATOR_H

#include <QMainWindow>

namespace Ui {
class Calculator;
}

class Calculator : public QMainWindow
{
    Q_OBJECT

public:
    explicit Calculator(QWidget *parent = nullptr);
    ~Calculator();

private:
    Ui::Calculator *ui;

    double currentValue;  //当前处理的值
    double storedValue;   //累积存储下来的值
    QString currentOperation;
    bool waitingForOperand;
    bool hasDecimal;

    void resetCalculator();  //重设计算器
    void abortOperation();
    void setDisplay(double value);
    void calculate(double operand, const QString &operation);

private slots:
    void digitClicked();  //数字符号按钮

    void plusClicked();  //+
    void minusClicked();  //-
    void multiplyClicked();  //乘
    void divideClicked();   //除
    void equalsClicked();  //=

    void clearClicked();  //C
    void clearAllClicked();  //CE
    void signClicked();  //+/-
    void decimalClicked();  //小数点
    void reciprocalClicked();   //倒数
    void squareClicked();  //sqrt
};

#endif // CALCULATOR_H
